package com.asset.dispoal.extension.strategy.command;

import com.asset.dispoal.extension.domain.dto.RolePermissionDTO;
import com.asset.dispoal.extension.strategy.BaseDataPowerStrategyServer;
import org.springframework.stereotype.Component;
import tech.mhuang.pacebox.core.strategy.StrategyHandlerParam;
import tech.mhuang.pacebox.core.strategy.StrategyHandlerResult;

import java.util.Collections;
import java.util.List;

/**
 * 本部门
 *
 * @author mhuang
 * @since 1.0.0
 */
@Component
public class TheDepartmentDataPowerStrategyServer implements BaseDataPowerStrategyServer {
    @Override
    public StrategyHandlerResult<String> strategy(StrategyHandlerParam<RolePermissionDTO> strategyHandlerParam) {
        RolePermissionDTO dto = strategyHandlerParam.getData();
        String sqlHeader = " select 3 from sys_department_user dep" +
                "  where dep.user_id = " +
                dto.getCarry() +
                "  and dep.department_id in ( select department_id from sys_department_user where user_id ='" +
                dto.getUserId() +
                "')";
        return new StrategyHandlerResult<>(true, sqlHeader);
    }

    @Override
    public List<String> event() {
        return Collections.singletonList("3");
    }
}
